package com.song.controller;

import com.song.model.Student;
import com.song.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @ClassName : StudentController
 * @Author : 司猫子
 * @Date: 2021/3/1 18:37
 */
@Controller
public class StudentController {
    @Resource
    private StudentService studentService;

    @RequestMapping("/add")
    @ResponseBody
    public String addStudent(Integer age,String name){
        int i = studentService.addStudent(name, age);
        return "注册学生的操作:"+ (i > 0?"添加学生成功":"注册学生失败");
    }

    @RequestMapping("/query")
    @ResponseBody
    public Student queryById(Integer id){
        Student student = studentService.queryById(id);
        return student;
    }

}
